home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / New System Software Extensions / SCSI Manager 4.3f1 / Header files / ACAM.h next >
Encoding:
C/C++ Source or Header  |  1993-09-28  |  26.8 KB  |  677 lines  |  [TEXT/MPS ]

  1. /*******************************************************************************
  2.  
  3.     File:        ACAM.h
  4.  
  5.     Contains:    
  6.         This file contains constants and data structures that will be used by
  7.         drivers to interface with the SCSI Manager 4.3.
  8.                         
  9.         ---------------------------------        SCSI Manager Header File
  10.         --- S C S I   M A N A G E R   ---        Version 4.3
  11.         ---------------------------------        
  12.  
  13. *******************************************************************************/
  14.  
  15. #ifndef __ACAM__
  16. #define __ACAM__    1
  17.  
  18. #include <Timer.h>
  19. #include <Types.h>
  20. #include <Traps.h>
  21. #include <OSUtils.h>
  22.  
  23. #ifndef uchar
  24. #define uchar    unsigned char
  25. #endif
  26. #ifndef ushort
  27. #define ushort    unsigned short
  28. #endif
  29. #ifndef ulong
  30. #define ulong    unsigned long
  31. #endif
  32.  
  33. #define true 1
  34. #define false 0
  35.  
  36. #define scsiVERSION 43
  37.  
  38. /********************************************************************/
  39. // Defines for the SCSIMgr function codes
  40. /********************************************************************/
  41.  
  42. enum                                         // <SM9> changed to enums as per design review
  43. {
  44. //------------ Common Functions ------------
  45.  
  46.     SCSINop                        = 0x00,      // Execute nothing
  47.     SCSIExecIO                      = 0x01,      // Execute the specified IO
  48.     SCSIBusInquiry              = 0x03,     // Get parameters for entire path of HBAs
  49.     SCSIReleaseQ                = 0x04,        // Release the frozen SCM queue for particular LUN 
  50.     SCSISetAsyncCallback        = 0x05,        // Set async event call back 
  51.  
  52. //------------ Control Functions         ------------
  53.  
  54.     SCSIAbortCommand            = 0x10,        // Abort the selected Control Block 
  55.     SCSIResetBus                = 0x11,        // Reset the SCSI bus 
  56.     SCSIResetDevice                = 0x12,        // Reset the SCSI device 
  57.     SCSITerminateIO                = 0x13,        // Terminate any pending IO 
  58.  
  59. //------------ Target Mode Functions      ------------
  60.  
  61.     SCSIEnableLUN                = 0x30,        // Enable LUN, Target mode support
  62.     SCSITargetIO                = 0x31,        // Execute the target IO request
  63.  
  64. //------------ Apple Added                 ------------
  65.  
  66.     SCSIGetVirtualIDInfo        = 0x80,        // Find out which bus old ID is on                            
  67.     SCSIGenerateInterleaveID    = 0x81,        // Generate a new interleave factor        <SM9> pdw
  68.     SCSILoadDriver                = 0x82,        // Load a driver for a device ident.    <LW6> DCB
  69.     SCSIOldCall                    = 0x84,        // XPT->SIM private call for old-API
  70.     SCSICreateRefNumXref        = 0x85,        // Register a DeviceIdent to drvr RefNum xref
  71.     SCSILookupRefNumXref        = 0x86,        // Get DeviceIdent to drvr RefNum xref
  72.     SCSIRemoveRefNumXref        = 0x87,        // Remove a DeviceIdent to drvr RefNum xref
  73.     SCSIRegisterWithNewXPT        = 0x88        // XPT has changed - SIM needs to re-register itself
  74.  
  75. //------------ 3rd-party Vendor Unique     ------------                            
  76.  
  77. // 0xC0 thru 0xFF
  78. };
  79.  
  80.  
  81. /********************************************************************/
  82. /*    SCSI Parameter Block Elements                                    */
  83. /********************************************************************/
  84.  
  85. typedef pascal void (*CallbackProc) (void * ioPtr);                    //            <SM6> pdw
  86.  
  87.  
  88. //————— Allocation length defines for some of the fields ————— <SM9>
  89.  
  90. #define        handshakeDataLength        8        // Handshake data length
  91. #define        maxCDBLength            16         // Space for the CDB bytes/pointer
  92. #define        vendorIDLength            16      // ASCII string len for Vendor ID 
  93.  
  94.  
  95. //————— Define DeviceIdent structure —————
  96.  
  97. typedef struct DeviceIdent 
  98. {
  99.     uchar        diReserved;            // reserved
  100.     uchar        bus;                // SCSI - Bus #
  101.     uchar        targetID;            // SCSI - Target SCSI ID
  102.     uchar        LUN;                // SCSI - LUN 
  103. } DeviceIdent;
  104.  
  105.  
  106. //————— Command Descriptor Block structure —————
  107.  
  108. typedef union CDB
  109. {
  110.     uchar *        cdbPtr;                        // ptr to the CDB bytes to send, or…
  111.     uchar        cdbBytes[ maxCDBLength ];    // actual CDB to send                    <SM6> pdw
  112. } CDB, *CDBPtr;
  113.  
  114.  
  115. //————— Scatter/gather list element —————
  116.  
  117. typedef    struct SGRecord 
  118. {
  119.     Ptr        SGAddr;
  120.     ulong    SGCount;
  121. } SGRecord;
  122.  
  123.  
  124.  
  125.  
  126. /********************************************************************/
  127. /*    SCSI Parameter Block Definitions                                */
  128. /********************************************************************/
  129.  
  130. //====== Common SCSI PB header fields macro ======
  131.  
  132. #define SCSIPBHdr \
  133.     struct SCSIHdr * qLink;                /* (internal) Q link to next PB         */ \
  134.     short            scsiReserved1;        /* ->     reserved for input                */ \
  135.     ushort            scsiPBLength;        /* -> Length of the entire PB            */ \
  136.     uchar            scsiFunctionCode;    /* -> function selector                 */ \
  137.     uchar            scsiReserved2;        /* <-     reserved for output                */ \
  138.     OSErr            scsiResult;            /* <- Returned result                     */ \
  139.     DeviceIdent        scsiDevice;            /* -> Device Identifier (bus+target+lun)*/ \
  140.     CallbackProc    scsiCompletion;        /* -> Callback on completion function      */ \
  141.     ulong            scsiFlags;            /* -> assorted flags                    */ \
  142.     uchar *            scsiDriverStorage;    /* <> Ptr for driver private use        */ \
  143.     Ptr                scsiXPTprivate;        /* private field for use in XPT            */ \
  144.     long            scsiReserved3;        /* reserved                                */
  145. // end of SCSIPBHdr
  146.  
  147.  
  148. //——————————————  SCSI PB Header  ——————————————
  149.  
  150. typedef struct SCSIHdr
  151. {
  152.     SCSIPBHdr
  153. } SCSIHdr;
  154.  
  155. typedef struct SCSI_PB
  156. {
  157.     SCSIPBHdr
  158. } SCSI_PB;
  159.  
  160.  
  161. //——————————————  SCSI I/O Request PB  ——————————————        <SM6> pdw from prev <SM6>
  162.                                                                 
  163. #define SCSI_IO_Macro \
  164.     SCSIPBHdr                            /* Header information fields                        */ \
  165.     ushort        scsiResultFlags;        /* <- Flags which modify the scsiResult field        */ \
  166.     ushort        scsiInterleaveID;        /* -> used to designate interleavability of request    */ \
  167.     uchar *        scsiDataPtr;            /* -> Pointer to the data buffer or the S/G list      */ \
  168.     ulong        scsiDataLength;            /* -> Data transfer length                            */ \
  169.     uchar *        scsiSensePtr;            /* -> Ptr to autosense data buffer                  */ \
  170.     uchar        scsiSenseLength;        /* -> size of the autosense buffer                     */ \
  171.     uchar        scsiCDBLength;            /* -> Number of bytes for the CDB                      */ \
  172.     ushort        scsiSGListCount;        /* -> num of scatter gather list entries              */ \
  173.     ulong        scsiReserved4;            /* <-     reserved for output                            */ \
  174.     uchar        scsiSCSIstatus;            /* <- Returned scsi device status                      */ \
  175.     char        scsiSenseResidual;        /* <- Autosense residual length                      */ \
  176.     ushort        scsiReserved5;            /* <-     reserved for output                             */ \
  177.     long        scsiDataResidual;        /* <- Returned Transfer residual length              */ \
  178.     CDB            scsiCDB;                /* -> Actual CDB or pointer to CDB                  */ \
  179.     long        scsiTimeout;            /* -> Timeout value (Time Mgr format) (CAM timeout) */ \
  180.     uchar *        scsiMessagePtr;            /* -> Pointer to the message buffer -target md only    */ \
  181.     ushort        scsiMessageLen;            /* -> Num of bytes in the msg bfr    -target md only    */ \
  182.     ushort        scsiIOFlags;            /* -> additional I/O flags                               */ \
  183.     uchar        scsiTagAction;            /* -> What to do for tag queuing                       */ \
  184.     uchar        scsiReserved6;            /* ->     reserved for input                             */ \
  185.     ushort        scsiReserved7;            /* ->     reserved for input                             */ \
  186.     ushort        scsiSelectTimeout;        /* -> Select timeout value                             */ \
  187.     uchar        scsiDataType;            /* -> Data description type (i.e. buffer, TIB, S/G)    */ \
  188.     uchar        scsiTransferType;        /* -> Transfer type (i.e. Blind vs Polled)             */ \
  189.     ulong        scsiReserved8;            /* ->     reserved for input                             */ \
  190.     ulong        scsiReserved9;            /* ->     reserved for input                             */ \
  191.     ushort        scsiHandshake[handshakeDataLength];    /* -> handshaking points (null term'd)    */ \
  192.     ulong        scsiReserved10;            /* ->     reserved for input                             */ \
  193.     ulong        scsiReserved11;            /* ->   reserved for input                            */ \
  194.     struct SCSI_IO *scsiCommandLink;    /* -> Ptr to the next PB in linked cmd chain         */ \
  195.                                         \
  196.     uchar        scsiSIMpublics[8];        /* ->     reserved for input to 3rd-party SIMs        */ \
  197.     uchar        scsiAppleReserved6[8];    /* ->    reserved for input                              */ \
  198.                                         \
  199. /* XPT layer privates (for old-API emulation) */ \
  200.                                         \
  201.     ushort        scsiCurrentPhase;        /* <- phase upon completing old call                  */ \
  202.     short        scsiSelector;            /* -> selector specified in old calls                  */ \
  203.     OSErr        scsiOldCallResult;        /* <- result of old call                              */ \
  204.     uchar        scsiSCSImessage;        /* <- Returned scsi device message (for SCSIComplete)*/ \
  205.     uchar        XPTprivateFlags;        /* <> various flags                                   */ \
  206.     uchar        XPTextras[12];            /*                                                    */
  207.  
  208. // end of SCSI_IO_Macro
  209.  
  210.  
  211. typedef struct SCSI_IO
  212. {
  213.     SCSI_IO_Macro
  214. } SCSI_IO;
  215. //                                                                <SM6> pdw from prev <SM6>
  216. #define SCSIExecIOPB    SCSI_IO
  217.     
  218.  
  219.     
  220.  
  221. //——————————————  Bus inquiry PB ——————————————
  222. typedef struct SCSIBusInquiryPB
  223. {
  224.     SCSIPBHdr                            // Header information fields
  225.     ushort        scsiEngineCount;        // <- Number of engines on HBA
  226.     ushort        scsiMaxTransferType;    // <- Number of transfer types for this HBA
  227.  
  228.     ulong        scsiDataTypes;            // <- which data types are supported by this SIM
  229.  
  230.     ushort        scsiIOpbSize;            // <- Size of SCSI_IO PB for this SIM/HBA        <SM6> pdw
  231.     ushort        scsiMaxIOpbSize;        // <- Size of max SCSI_IO PB for all SIM/HBAs    <SM6> pdw
  232.     
  233.     ulong        scsiFeatureFlags;        // <- Supported features flags field
  234.  
  235.     uchar        scsiVersionNumber;        // <- Version number for the SIM/HBA
  236.     uchar        scsiHBAInquiry;            // <- Mimic of INQ byte 7 for the HBA
  237.     uchar        scsiTargetModeFlags;    // <- Flags for target mode support
  238.     uchar        scsiScanFlags;            // <- Scan related feature flags
  239.  
  240.     ulong        scsiSIMPrivatesPtr;        // <- Ptr to SIM private data area
  241.     ulong        scsiSIMPrivatesSize;    // <- Size of SIM private data area
  242.     ulong        scsiAsyncFlags;            // <- Event cap. for Async Callback
  243.  
  244.     uchar        scsiHiBusID;            // <- Highest path ID in the subsystem 
  245.     uchar        scsiInitiatorID;        // <- ID of the HBA on the SCSI bus
  246.     ushort        scsiBIReserved0;
  247.  
  248.     ulong        scsiBIReserved1;        // <- 
  249.     ulong        scsiFlagsSupported;        // <- which scsiFlags are supported
  250.  
  251.     ushort        scsiIOFlagsSupported;    // <- which scsiIOFlags are supported
  252.     ushort         scsiBIReserved2;        // <- 
  253.     ushort        scsiMaxTarget;            // <- maximum Target number supported
  254.     ushort        scsiMaxLUN;                // <- maximum Logical Unit number supported
  255.  
  256.     char        scsiSIMVendor[ vendorIDLength ];        // <- Vendor ID of SIM (or XPT if bus<FF)    <SM6> pdw
  257.     char        scsiHBAVendor[ vendorIDLength ];        // <- Vendor ID of the HBA                 <SM6> pdw
  258.     char        scsiControllerFamily[ vendorIDLength ];    // <- Family of SCSI Controller
  259.     char        scsiControllerType[ vendorIDLength ];    // <- Specific Model of SCSI Controller used
  260.  
  261.     char        scsiXPTversion[4];        // <- version number of XPT
  262.     char        scsiSIMversion[4];        // <- version number of SIM
  263.     char        scsiHBAversion[4];        // <- version number of HBA
  264.     
  265.     uchar        scsiHBAslotType;        // <- type of "slot" that this HBA is in
  266.     uchar        scsiHBAslotNumber;        // <- slot number of this HBA
  267.     ushort        scsiSIMsRsrcID;            // <- resource ID of this SIM
  268.     
  269.     ushort         scsiBIReserved3;        // <- 
  270.     ushort        scsiAdditionalLength;    // <- additional BusInquiry PB len
  271. } SCSIBusInquiryPB;
  272.  
  273.  
  274. //——————————————  Abort SIM Request PB  ——————————————
  275. typedef struct SCSIAbortCommandPB
  276. {
  277.     SCSIPBHdr                            // Header information fields
  278.     SCSI_IO *     scsiIOptr;                // Pointer to the PB to abort
  279. } SCSIAbortCommandPB;                    // <SM3>
  280.  
  281.  
  282. //——————————————  Terminate I/O Process Request PB  ——————————————
  283. typedef struct SCSITerminateIOPB
  284. {
  285.     SCSIPBHdr                            // Header information fields
  286.     SCSI_IO *     scsiIOptr;                // Pointer to the PB to terminate
  287. } SCSITerminateIOPB;                    // <SM3>
  288.  
  289.  
  290. //——————————————  Reset SCSI Bus PB ——————————————
  291. typedef struct SCSIResetBusPB
  292. {
  293.     SCSIPBHdr                            // Header information fields
  294. } SCSIResetBusPB;                        // <SM3>
  295.  
  296.  
  297. //——————————————  Reset SCSI Device PB  ——————————————
  298. typedef struct SCSIResetDevicePB
  299. {
  300.     SCSIPBHdr                            // Header information fields
  301. } SCSIResetDevicePB;                    // <SM3>
  302.  
  303.  
  304. //——————————————  Release SIM Queue PB  ——————————————
  305. typedef struct SCSIReleaseQPB
  306. {
  307.     SCSIPBHdr                            // Header information fields
  308. } SCSIReleaseQPB;
  309.  
  310.  
  311. //——————————————  Set Async Event Callback PB  ——————————————
  312. typedef struct SCSISetAsyncCallbackPB
  313. {
  314.     SCSIPBHdr                            // Header information fields
  315.     ulong        scsiEventFlags;            // -> events to be notified of
  316.     void        (*scsiEventCallback)();    // -> routine to call when event occurs
  317.     uchar *        scsiEventInfoPtr;        // -> ptr to buffer for additional info
  318.     uchar        scsiEventInfoLen;        // -> length of buffer
  319.     uchar        scsiReserved11;            // 
  320.     ushort        scsiReserved12;            // 
  321. } SCSISetAsyncCallbackPB;
  322.  
  323.  
  324. //——————————————  SCSI Get Virtual ID Info PB  ——————————————                                    <SM6> pdw
  325. typedef struct SCSIGetVirtualIDInfoPB
  326. {
  327.     SCSIPBHdr                        // Header information fields 
  328.     ushort        scsiOldCallID;        // -> SCSI ID of device in question
  329.     Boolean        scsiExists;            // <- true if device exists
  330. } SCSIGetVirtualIDInfoPB;
  331.  
  332.  
  333. //——————————————  SCSI Generate Interleave ID PB  ——————————————                                    <SM6> pdw
  334. typedef struct SCSIGenerateInterleaveIDPB
  335. {
  336.     SCSIPBHdr                        // Header information fields 
  337.     ushort        scsiInterleaveID;    // <- SCSI ID of device in question
  338.     ushort        scsiReserved13;        // 
  339. } SCSIGenerateInterleaveIDPB;
  340.  
  341.  
  342. //——————————————  Create/Lookup/Remove RefNum for Device PB  ——————————————
  343. typedef struct SCSI_Driver_PB
  344. {
  345.     SCSIPBHdr                            // Header information fields
  346.     short        scsiDriver;                // -> DriverRefNum, For SetDriver
  347.                                         // <- For GetNextDriver
  348.     ushort        scsiDriverFlags;        // <> Details of driver/device
  349.     DeviceIdent    scsiNextDevice;            // <- DeviceIdent of the NEXT Item in the list 
  350. } SCSI_Driver_PB;
  351.  
  352.  
  353. //——————————————  Load Driver PB ——————————————    <LW6> DCB
  354. typedef struct SCSILoadDriverPB
  355. {
  356.     SCSIPBHdr                            // Header information fields
  357.     short        scsiLoadedRefNum;        // <- SIM returns refnum of driver
  358.     Boolean        scsiDiskLoadFailed;        // -> if true, indicates call after failure to load
  359. } SCSILoadDriverPB;                        //
  360.  
  361. //======================================================================
  362.  
  363. /******************************************************************************/
  364. // Values for the fields in SCSI PBs
  365. /******************************************************************************/
  366.  
  367. //———————————————————————————————————————————————————————————————————————————————————
  368. // Defines for the scsiTransferType field
  369. //———————————————————————————————————————————————————————————————————————————————————
  370.  
  371. enum {
  372.         scsiTransferBlind = 0,
  373.         scsiTransferPolled
  374. };    
  375.  
  376. //———————————————————————————————————————————————————————————————————————————————————
  377. // Defines for the scsiDataType field
  378. //———————————————————————————————————————————————————————————————————————————————————
  379.  
  380. enum {
  381.         scsiDataBuffer     = 0,        // single contiguous buffer supplied 
  382.         scsiDataTIB     = 1,        // TIB supplied (ptr in scsiDataPtr)
  383.         scsiDataSG         = 2            // scatter/gather list supplied 
  384. };    
  385.  
  386. //———————————————————————————————————————————————————————————————————————————————————
  387. // Defines for the SCSIMgr scsiResult field in the PB header.
  388. //  $E100 thru  E1FF
  389. // -$1EFF thru -1E00
  390. // -#7935 thru -7681 
  391. //———————————————————————————————————————————————————————————————————————————————————
  392.  
  393. #define        scsiErrorBase        -7936                    // = 0xE100 
  394.  
  395. enum {                                                // <SM9> changed to enums
  396.     scsiRequestInProgress        = 1,                    // 1     = PB request is in progress
  397.  
  398. // Execution failed  00-2F
  399.     scsiRequestAborted            = (scsiErrorBase+0x02),    // -7934 = PB request aborted by the host
  400.     scsiUnableToAbort            = (scsiErrorBase+0x03),    // -7933 = Unable to Abort PB request
  401.     scsiNonZeroStatus            = (scsiErrorBase+0x04),    // -7932 = PB request completed with an err
  402.     scsiUnused05                = (scsiErrorBase+0x05),    // -7931 = 
  403.     scsiUnused06                = (scsiErrorBase+0x06),    // -7930 = 
  404.     scsiUnused07                = (scsiErrorBase+0x07),    // -7929 = 
  405.     scsiUnused08                = (scsiErrorBase+0x08),    // -7928 = 
  406.     scsiUnableToTerminate        = (scsiErrorBase+0x09),    // -7927 = Unable to Terminate I/O PB req
  407.     scsiSelectTimeout            = (scsiErrorBase+0x0A),    // -7926 = Target selection timeout
  408.     scsiCommandTimeout            = (scsiErrorBase+0x0B),    // -7925 = Command timeout 
  409.     scsiUnused0C                = (scsiErrorBase+0x0C),    // -7924 = 
  410.     scsiMessageRejectReceived    = (scsiErrorBase+0x0D),    // -7923 = Message reject received 
  411.     scsiSCSIBusReset            = (scsiErrorBase+0x0E),    // -7922 = SCSI bus reset sent/received
  412.     scsiParityError                = (scsiErrorBase+0x0F),    // -7921 = Uncorrectable parity error occured
  413.     scsiAutosenseFailed            = (scsiErrorBase+0x10),    // -7920 = Autosense: Request sense cmd fail
  414.     scsiUnused11                = (scsiErrorBase+0x11),    // -7919 = 
  415.     scsiDataRunError            = (scsiErrorBase+0x12),    // -7918 = Data overrun/underrun error 
  416.     scsiUnexpectedBusFree        = (scsiErrorBase+0x13),    // -7917 = Unexpected BUS free 
  417.     scsiSequenceFailed            = (scsiErrorBase+0x14),    // -7916 = Target bus phase sequence failure
  418.     scsiUnused15                = (scsiErrorBase+0x15),    // -7915 = 
  419.     privErrSelected                = (scsiErrorBase+0x16),    // -7914 = 
  420.     scsiBDRsent                    = (scsiErrorBase+0x17),    // -7913 = A SCSI BDR msg was sent to target
  421.     scsiTerminated                = (scsiErrorBase+0x18),    // -7912 = PB request terminated by the host
  422.     scsiNoNexus                    = (scsiErrorBase+0x19),    // -7911 = Nexus is not established
  423.     scsiCDBReceived                = (scsiErrorBase+0x1A),    // -7910 = The SCSI CDB has been received
  424.  
  425. // Couldn't begin execution  30-3F
  426.     scsiTooManyBuses            = (scsiErrorBase+0x30),    // -7888 = Register failed because we're full
  427.     scsiBusy                    = (scsiErrorBase+0x31),    // -7887 = SCSI subsystem is busy
  428.     scsiProvideFail                = (scsiErrorBase+0x32),    // -7886 = Unable to provide requ. capability
  429.     scsiDeviceNotThere            = (scsiErrorBase+0x33),    // -7885 = SCSI device not installed/there 
  430.     scsiNoHBA                    = (scsiErrorBase+0x34),    // -7884 = No HBA detected Error
  431.     scsiDeviceConflict            = (scsiErrorBase+0x35),    // -7883 = sorry, max 1 refNum per DeviceIdent
  432.     scsiNoSuchXref                = (scsiErrorBase+0x36),    // -7882 = no such RefNum xref
  433.     scsiQLinkInvalid            = (scsiErrorBase+0x37),    // -7881 = pre-linked PBs not supported    // <LW14> pdw Fß
  434.  
  435. // Parameter errors  40-7F
  436.     scsiPBLengthError            = (scsiErrorBase+0x40),    // -7872 = length (scsiPBLength) is insuf'ct/invalid
  437.     scsiFunctionNotAvailable    = (scsiErrorBase+0x41),    // -7871 = The requ. func is not available 
  438.     scsiRequestInvalid            = (scsiErrorBase+0x42),    // -7970 = PB request is invalid
  439.     scsiBusInvalid                = (scsiErrorBase+0x43),    // -7969 = Bus ID supplied is invalid 
  440.     scsiTIDInvalid                = (scsiErrorBase+0x44),    // -7868 = Target ID supplied is invalid
  441.     scsiLUNInvalid                = (scsiErrorBase+0x45),    // -7867 = LUN supplied is invalid 
  442.     scsiIIDInvalid                = (scsiErrorBase+0x46),    // -7866 = The initiator ID is invalid 
  443.     scsiDataTypeInvalid            = (scsiErrorBase+0x47),    // -7865 = scsiDataType requested is not supported
  444.     scsiTransferTypeInvalid        = (scsiErrorBase+0x48),    // -7864 = scsiTransferType field is too high
  445.     scsiCDBLengthInvalid        = (scsiErrorBase+0x49)    // -7863 = scsiCDBLength field is too big
  446. };
  447.  
  448. #define scsiExecutionErrors        scsiErrorBase
  449. #define scsiNotExecutedErrors    scsiTooManyBuses
  450. #define scsiParameterErrors        scsiPBLengthError
  451.  
  452. //———————————————————————————————————————————————————————————————————————————————————
  453. //  Defines for the scsiResultFlags field
  454. //———————————————————————————————————————————————————————————————————————————————————
  455.  
  456. #define    scsiSIMQFrozen            0x0001    // The SIM queue is frozen w/this err
  457. #define    scsiAutosenseValid        0x0002    // Autosense data valid for target 
  458. #define    scsiBusNotFree            0x0004    // At time of callback, SCSI bus is not free 
  459.  
  460.  
  461. //———————————————————————————————————————————————————————————————————————————————————
  462. // Defines for the scsiFlags field in the PB header for the SCSIExecIO function
  463. //———————————————————————————————————————————————————————————————————————————————————
  464.  
  465. // 1st Byte
  466.  
  467. #define    scsiDirectionMask        0xC0000000    // Data direction mask
  468.  
  469. #define scsiDirectionNone        0xC0000000    // Data direction (11: no data)
  470. #define    scsiDirectionReserved    0x00000000    // Data direction (00: reserved)
  471. #define    scsiDirectionOut        0x80000000    // Data direction (10: DATA OUT)
  472. #define    scsiDirectionIn            0x40000000    // Data direction (01: DATA IN)
  473. #define    scsiDisableAutosense    0x20000000    // Disable auto sense feature
  474. #define    scsiFlagReservedA        0x10000000    // 
  475.  
  476. #define    scsiFlagReserved0        0x08000000    // 
  477. #define    scsiCDBLinked            0x04000000    // The PB contains a linked CDB
  478. #define    scsiQEnable                0x02000000    // Target queue actions are enabled
  479. #define    scsiCDBIsPointer        0x01000000    // The CDB field contains a pointer
  480.  
  481. // 2nd Byte
  482.  
  483. #define    scsiFlagReserved1        0x00800000    // 
  484. #define    scsiInitiateSyncData    0x00400000    // Attempt Sync data xfer and SDTR
  485. #define    scsiDisableSyncData        0x00200000    // Disable sync, go to async
  486. #define    scsiSIMQHead            0x00100000    // Place PB at the head of SIM Q
  487.  
  488. #define    scsiSIMQFreeze            0x00080000    // Return the SIM Q to frozen state
  489. #define    scsiSIMQNoFreeze        0x00040000    // Disallow SIM Q freezing
  490. #define    scsiDoDisconnect        0x00020000    // Definitely do disconnect
  491. #define    scsiDontDisconnect        0x00010000    // Definitely don't disconnect
  492.  
  493. // 3rd Byte
  494.  
  495. #define    scsiFlagReserved3        0x00008000    // 
  496. #define    scsiDataDMAready        0x00004000    // Data buffer(s) are ready for DMA
  497. #define    scsiDataPhysical        0x00002000    // SG/Buffer data ptrs are physical
  498. #define    scsiSensePhysical        0x00001000    // Autosense buffer ptr is physical
  499.  
  500. #define    scsiFlagReserved5        0x00000800    // 
  501. #define    scsiFlagReserved6        0x00000400    // 
  502. #define    scsiFlagReserved7        0x00000200    // 
  503. #define    scsiFlagReserved8        0x00000100    // 
  504.  
  505. // 4th Byte - Target Mode Flags
  506.  
  507. #define    scsiDataBufferValid            0x00000080    // Data buffer valid
  508. #define    scsiStatusBufferValid        0x00000040    // Status buffer valid 
  509. #define    scsiMessageBufferValid        0x00000020    // Message buffer valid
  510. #define    scsiFlagReserved9            0x00000010    // 
  511.  
  512. #define    scsiTargetPhaseMode            0x00000008    // The SIM will run in phase mode
  513. #define    scsiTargetPBAvail            0x00000004    // Target PB available 
  514. #define    scsiDisableAutoDisconnect    0x00000002    // Disable autodisconnect
  515. #define    scsiDisableAutoSaveRestore    0x00000001    // Disable autosave/restore ptrs
  516.  
  517. #define    scsiTargetModeFlagsMask        0x000000FF    // all of the target mode bits
  518.  
  519.  
  520.  
  521. //————————————————————————————————————————
  522. // scsiIOFlags
  523. //————————————————————————————————————————
  524.  
  525. #define    scsiNoParityCheck            0x0002    // disable parity checking 
  526. #define    scsiDisableSelectWAtn        0x0004    // disable select w/Atn 
  527. #define    scsiSavePtrOnDisconnect        0x0008    // do SaveDataPointer upon Disconnect msg
  528. #define    scsiNoBucketIn                0x0010    // don’t bit bucket in during this I/O
  529. #define    scsiNoBucketOut                0x0020    // don’t bit bucket out during this I/O
  530. #define    scsiDisableWide                0x0040    // disable wide transfer negotiation
  531. #define    scsiInitiateWide            0x0080    // initiate wide transfer negotiation
  532. #define    scsiRenegotiateSense        0x0100    // renegotiate sync/wide before issuing autosense
  533.  
  534. #define    scsiIOFlagReserved0080        0x0080    // 
  535. #define    scsiIOFlagReserved8000        0x8000    // 
  536.  
  537.  
  538. //——————————————————————————————————————————————————————————————————————
  539. // Defines for the SIM/HBA queue actions.  These values are used in the
  540. // SCSIExecIOPB, for the queue action field. [These values should match the
  541. // defines from some other include file for the SCSI message phases.  We may
  542. // not need these definitions here. ]
  543.  
  544. enum
  545. {
  546.     scsiSimpleQTag            = 0x20,        // Tag for a simple queue
  547.     scsiHeadQTag            = 0x21,        // Tag for head of queue 
  548.     scsiOrderedQTag            = 0x22         // Tag for ordered queue 
  549. };
  550.  
  551. //——————————————————————————————————————————————————————————————————————
  552. // Defines for the Bus Inquiry PB fields.
  553. //——————————————————————————————————————————————————————————————————————
  554.  
  555. // scsiHBAInquiry field bits
  556.  
  557. #define    scsiBusMDP                0x80    // Supports Modify Data Pointer message
  558. #define    scsiBusWide32            0x40    // Supports 32 bit wide SCSI
  559. #define    scsiBusWide16            0x20    // Supports 16 bit wide SCSI
  560. #define    scsiBusSDTR                0x10    // Supports Sync Data Transfer Req message
  561. #define    scsiBusLinkedCDB        0x08    // Supports linked CDBs
  562. #define    scsiBusTagQ                0x02    // Supports tag queue message 
  563. #define    scsiBusSoftReset        0x01    // Supports soft reset
  564.  
  565.  
  566. // scsiDataTypes field bits 
  567. //    bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved
  568.  
  569. #define scsiBusDataTIB            (1<<scsiDataTIB)        // TIB supplied (ptr in scsiDataPtr)
  570. #define scsiBusDataBuffer        (1<<scsiDataBuffer)    // single contiguous buffer supplied 
  571. #define scsiBusDataSG            (1<<scsiDataSG)        // scatter/gather list supplied 
  572.  
  573. #define scsiBusDataReserved        0x80000000    //  
  574.  
  575.  
  576. // scsiTargetModeFlags field bits
  577.  
  578. #define scsiBusTargetMdProcessor    0x80    // Target mode processor mode 
  579. #define scsiBusTargetMdPhase        0x40    // Target mode phase cog. mode
  580.  
  581.  
  582. // scsiScanFlags field bits
  583.  
  584. #define scsiBusScansDevices            0x80    // Bus scans for and maintains device list
  585. #define scsiBusScansOnInit            0x40    // Bus scans performed at power-up/reboot
  586. #define scsiBusLoadsROMDrivers        0x20    // may load ROM drivers to support targets
  587.  
  588.  
  589. // scsiFeatureFlags field bits
  590.  
  591. #define scsiBusInternalExternalMask        0x000000C0    // bus internal/external mask
  592. #define scsiBusInternalExternalUnknown    0x00000000    // not known whether bus is inside or outside
  593. #define scsiBusInternalExternal            0x000000C0    // bus goes inside and outside the box
  594. #define scsiBusInternal                    0x00000080    // bus goes inside the box
  595. #define scsiBusExternal                    0x00000040    // bus goes outside the box
  596.  
  597. #define scsiBusCacheCoherentDMA            0x00000020    // DMA is cache coherent
  598. #define scsiBusOldCallCapable            0x00000010    // SIM is old call capable
  599.  
  600. #define scsiBusDifferential                0x00000004    // Single Ended (0) or Differential (1)
  601. #define scsiBusFastSCSI                    0x00000002    // HBA supports fast SCSI
  602. #define scsiBusDMAavailable                0x00000001    // DMA is available
  603.  
  604.  
  605. //———————————————————————————————————————————————————————————————————————————————————
  606. //  Defines for the scsiDriverFlags field (in SCSI_Driver_PB)
  607. //———————————————————————————————————————————————————————————————————————————————————
  608.  
  609. #define    scsiDeviceSensitive            0x0001    // Only driver should access this device
  610. #define    scsiDeviceNoOldCallAccess    0x0002    // no old call access to this device
  611.  
  612.  
  613.  
  614. //——————————————————————————————————————————————————————————————————————
  615. //  SIMinitInfo
  616. //——————————————————————————————————————————————————————————————————————
  617.  
  618. typedef struct {            // directions are for SCSIRegisterBus call ( -> parm, <- result)
  619.     uchar *        SIMstaticPtr;        // <- alloc. ptr to the SIM's static vars
  620.     long        staticSize;            // -> num bytes SIM needs for static vars
  621.     OSErr        (*SIMinit)();        // -> pointer to the SIM init routine
  622.     void        (*SIMaction)();        // -> pointer to the SIM action routine
  623.     long        (*SIM_ISR)();        // -> pointer to the SIM ISR routine
  624.     long        (*SIMInterruptPoll)();    // -> pointer to the SIM interrupt poll routine
  625.     void        (*NewOldCall)();    // -> pointer to the SIM NewOldCall routine
  626.     ushort        ioPBSize;            // -> size of SCSI_IO_PBs required for this SIM        <SM6> pdw
  627.     Boolean        oldCallCapable;        // -> true if this SIM can handle old-API calls
  628.     uchar        simInfoUnused1;        // ->
  629.     long        simInternalUse;        // xx not affected or viewed by XPT
  630.     void        (*XPT_ISR)();        // <- ptr to the XPT ISR
  631.     void        (*EnteringSIM)();    // <- ptr to the EnteringSIM routine
  632.     void        (*ExitingSIM)();    // <- ptr to the ExitingSIM routine
  633.     void        (*MakeCallback)();    // <- pointer to the XPT layer’s MakeCallback routine
  634.     ushort        busID;                // <- bus number for the registered bus
  635.     ushort        simInfoUnused3;        // <- 
  636.     long        simInfoUnused4;        // <- 
  637. } SIMinitInfo; 
  638.  
  639.  
  640.  
  641. /********* Glue between SCSI calls and SCSITrap format ***********/
  642.  
  643. enum {
  644.     xptSCSIAction            = 0x0001,
  645.     xptSCSIRegisterBus        = 0x0002,
  646.     xptSCSIDeregisterBus    = 0x0003,
  647.     xptSCSIReregisterBus    = 0x0004,
  648.     xptSCSIKillXPT            = 0x0005    // kills Mini-XPT after transition 
  649. };
  650.  
  651. #ifdef __cplusplus
  652. extern "C" {
  653. #endif
  654.  
  655. #pragma parameter __D0    SCSIAction(__A0)            /* moveq #kSCSIx, D0;  _SCSIAtomic */
  656. OSErr                    SCSIAction(SCSI_PB *)            = {0x7001, _SCSIAtomic}; 
  657.  
  658. #pragma parameter __D0    SCSIRegisterBus(__A0)
  659. OSErr                    SCSIRegisterBus(SIMinitInfo *)    = {0x7002, _SCSIAtomic}; 
  660.  
  661. #pragma parameter __D0    SCSIDeregisterBus(__A0)
  662. OSErr                    SCSIDeregisterBus(SIMinitInfo *)    = {0x7003, _SCSIAtomic}; 
  663.  
  664. #pragma parameter __D0    SCSIReRegisterBus(__A0)
  665. OSErr                    SCSIReRegisterBus(SIMinitInfo *)    = {0x7004, _SCSIAtomic}; 
  666.  
  667. #pragma parameter __D0    SCSIKillXPT(__A0)
  668. OSErr                    SCSIKillXPT(SIMinitInfo *)    = {0x7005, _SCSIAtomic}; 
  669.  
  670. #ifdef __cplusplus
  671. }
  672. #endif
  673.  
  674.  
  675.  
  676. #endif    // __ACAM__
  677.